import axios from 'axios'

const baseUrl = process.env.VUE_APP_API_BASE_URL
export default {
  language_url: '/tinymce/langs/zh_CN.js',
  skin_url: '/tinymce/skins/ui/oxide',
  menubar: false,
  toolbar: 'undo redo | bold italic underline strikethrough | numlist bullist  alignleft aligncenter alignright alignjustify image | fontselect fontsizeselect forecolor backcolor | link unlink  table | superscript subscript fullscreen |',
  toolbar_drawer: 'sliding',
  quickbars_selection_toolbar: '',
  quickbars_insert_toolbar: '',
  plugins: 'link image media table lists fullscreen quickbars paste',
  language: 'zh_CN',
  height: 300,
  elementpath: false,
  statusbar: false,
  placeholder: '在这里输入文字...',
  paste_retain_style_properties: 'all',
  paste_word_valid_elements: '*[*]',
  paste_data_images: true,
  paste_convert_word_fake_lists: false,
  paste_webkit_styles: 'all',
  paste_merge_formats: true,
  nonbreaking_force_tab: false,
  paste_auto_cleanup_on_paste: false,
  fontsize_formats: '10px 11px 12px 14px 16px 18px 20px 24px',
  font_formats: '宋体=宋体;黑体=黑体;仿宋=仿宋;楷体=楷体;隶书=隶书;幼圆=幼圆;Arial=arial,helvetica,sans-serif;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier;Tahoma=tahoma,arial,helvetica,sans-serif;Times New Roman=times new roman,times;Verdana=verdana,geneva;Webdings=webdings;Wingdings=wingdings,zapf dingbats',
  imagetools_toolbar: 'rotateleft rotateright | flipv fliph | editimage imageoptions',
  images_upload_handler: function (blobInfo, succFun, failFun) {
    const file = blobInfo.blob()
    const params = new FormData()
    params.append('file', file, file.name)
    const config = {
      headers: { 'Content-Type': 'multipart/form-data' }
    }
    axios.post(`${baseUrl}/common/commonFile/upload`, params, config).then(res => {
      if (res.data.code === 0) {
        const { path, domain } = res.data.content
        succFun(domain + path)
      }
    }).catch(res => {
      failFun('error')
    })
  }
}
